using System.ComponentModel;
using System.Windows.Forms;
using WindowsLive.Writer;
using SubtextSmiliesPlugin.Properties;

namespace SubtextSmiliesPlugin
{
	/// <summary>
	/// Summary description for SubtextSmiliesInsertForm.
	/// </summary>
	public class SubtextSmiliesInsertForm : Form
    {
        private SubtextSmiliesControl subtextSmiliesControl;
        private Button buttonOK;
        private Button buttonCancel;
        private TextBox textBox1;
        private Settings mus;
        private ToolTip toolTip1;
        private LinkLabel linkLabel1;
        private IContainer components;

		public SubtextSmiliesInsertForm()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
            this.components = new System.ComponentModel.Container();
            this.buttonOK = new System.Windows.Forms.Button();
            this.buttonCancel = new System.Windows.Forms.Button();
            this.textBox1 = new System.Windows.Forms.TextBox();
            this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
            this.linkLabel1 = new System.Windows.Forms.LinkLabel();
            this.subtextSmiliesControl = new SubtextSmiliesPlugin.SubtextSmiliesControl();
            this.SuspendLayout();
            // 
            // buttonOK
            // 
            this.buttonOK.DialogResult = System.Windows.Forms.DialogResult.OK;
            this.buttonOK.Enabled = false;
            this.buttonOK.Location = new System.Drawing.Point(4, 116);
            this.buttonOK.Name = "buttonOK";
            this.buttonOK.Size = new System.Drawing.Size(75, 23);
            this.buttonOK.TabIndex = 1;
            this.buttonOK.Text = "OK";
            this.buttonOK.UseVisualStyleBackColor = true;
            // 
            // buttonCancel
            // 
            this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
            this.buttonCancel.Location = new System.Drawing.Point(94, 116);
            this.buttonCancel.Name = "buttonCancel";
            this.buttonCancel.Size = new System.Drawing.Size(75, 23);
            this.buttonCancel.TabIndex = 2;
            this.buttonCancel.Text = "Cancel";
            this.buttonCancel.UseVisualStyleBackColor = true;
            // 
            // textBox1
            // 
            this.textBox1.Location = new System.Drawing.Point(4, 90);
            this.textBox1.Name = "textBox1";
            this.textBox1.Size = new System.Drawing.Size(165, 20);
            this.textBox1.TabIndex = 4;
            this.toolTip1.SetToolTip(this.textBox1, "Enter your root Subtext like http://www.yourdomain.com/blogs");
            this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
            // 
            // toolTip1
            // 
            this.toolTip1.IsBalloon = true;
            // 
            // linkLabel1
            // 
            this.linkLabel1.AutoSize = true;
            this.linkLabel1.Location = new System.Drawing.Point(3, 5);
            this.linkLabel1.Name = "linkLabel1";
            this.linkLabel1.Size = new System.Drawing.Size(168, 13);
            this.linkLabel1.TabIndex = 5;
            this.linkLabel1.TabStop = true;
            this.linkLabel1.Text = "http://www.analystdeveloper.com";
            this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel1_LinkClicked);
            // 
            // subtextSmiliesControl
            // 
            this.subtextSmiliesControl.Location = new System.Drawing.Point(4, 23);
            this.subtextSmiliesControl.Message = "<img  src=\"http://localhost/DasBlog/smilies/\"></img>";
            this.subtextSmiliesControl.Name = "subtextSmiliesControl";
            this.subtextSmiliesControl.Size = new System.Drawing.Size(165, 61);
            this.subtextSmiliesControl.TabIndex = 0;
            this.toolTip1.SetToolTip(this.subtextSmiliesControl, "Select a smiley :-)");
            this.subtextSmiliesControl.MessageChanged += new System.EventHandler(this.subtextSmiliesControl_MessageChanged);
            // 
            // SubtextSmiliesInsertForm
            // 
            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
            this.ClientSize = new System.Drawing.Size(173, 144);
            this.ControlBox = false;
            this.Controls.Add(this.linkLabel1);
            this.Controls.Add(this.textBox1);
            this.Controls.Add(this.buttonCancel);
            this.Controls.Add(this.buttonOK);
            this.Controls.Add(this.subtextSmiliesControl);
            this.MaximizeBox = false;
            this.MinimizeBox = false;
            this.Name = "SubtextSmiliesInsertForm";
            this.ShowInTaskbar = false;
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
            this.Text = "Insert DasBlog Smilies";
            this.Load += new System.EventHandler(this.SubtextSmiliesInsertForm_Load);
            this.ResumeLayout(false);
            this.PerformLayout();

		}
		#endregion

		public string Message
		{
			get { return subtextSmiliesControl.Message; }
			set { subtextSmiliesControl.Message = value; }
		}

        private void SubtextSmiliesInsertForm_Load(object sender, System.EventArgs e)
        {
            mus = new Settings();
            textBox1.Text = mus.siteURL;
        }

        private void subtextSmiliesControl_MessageChanged(object sender, System.EventArgs e)
        {
            this.buttonOK.Enabled = true;
        }

        private void textBox1_TextChanged(object sender, System.EventArgs e)
        {
            mus.siteURL = textBox1.Text;
            mus.Save();
        }

        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            linkLabel1.Links[linkLabel1.Links.IndexOf(e.Link)].Visited = true;
            System.Diagnostics.Process.Start(linkLabel1.Text);
        }
	}
}
